<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数</title>
</head>
<body>
    <!-- <button></button> -->
    <script>
        for(var i=0;i<4;i++){
            document.write("<button id='btn"+i+"' onclick='change("+i+")'>"+"按钮"+i+"</button>");
        }
        for(var i=0;i<4;i++){
            document.write("<div class='btnC'>div"+i+"</div>");
        }
        function change(num){
            let ele=document.getElementsByClassName("btnC")[num];
            ele.style.display=="none"?ele.style.display="block":ele.style.display="none";
        }
    </script>
</body>
</html>